package study;

import org.jboss.resteasy.logging.Logger;
import org.jboss.resteasy.spi.*;

import javax.ws.rs.WebApplicationException;
import java.lang.reflect.Type;

/**
 * Created by 徐翔 on 14-3-11.
 */
public class GuiceConstructorInjector implements ConstructorInjector {

    private Jedi jedi;
    private Type type;
    private static final Logger log = Logger.getLogger(GuiceConstructorInjector.class);
    public GuiceConstructorInjector(Type type, Jedi jedi){
        this.jedi = jedi;
        this.type = type;
    }
    @Override
    public Object construct() {
        return jedi.getInjector().getInstance(type.getClass());
    }

    @Override
    public Object construct(HttpRequest request, HttpResponse response) throws Failure, WebApplicationException, ApplicationException {
        return construct();
    }

    @Override
    public Object[] injectableArguments() {
        return new Object[0];
    }

    @Override
    public Object[] injectableArguments(HttpRequest request, HttpResponse response) throws Failure {
        return injectableArguments();
    }
}
